/**
 * Copyright (C), 2015-2018, XXX有限公司
 * FileName: GlobalExceptionHandle
 * Author:   zhouheng
 * Date:     2018/6/25 10:54
 * Description: 全局异常拦截器
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.hengby.hengcrud.core.aop;

import com.hengby.hengcrud.core.exception.HengCrudException;
import com.hengby.hengcrud.core.log.LogManager;
import com.hengby.hengcrud.core.log.factory.LogTaskFactory;
import com.hengby.hengcrud.core.shiro.ShiroKit;
import com.hengby.hengcrud.modular.sys.model.User;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authz.UnauthenticatedException;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * 〈一句话功能简述〉<br> 
 * 〈全局异常拦截器〉
 *
 * @author zhouheng
 * @create 2018/6/25
 * @since 1.0.0
 */
@ControllerAdvice
@Slf4j
@Order(-1)
public class GlobalExceptionHandle {


    /**
     * 用户未登陆异常
     */
    @ExceptionHandler(AuthenticationException.class)
    @ResponseStatus(HttpStatus.UNAUTHORIZED)
    public String unAuth(AuthenticationException e){
        log.error("用户未登陆：", e);
        return "login";
    }

}